package com.quick.develop.flowable.mapper;

import com.quick.develop.flowable.domain.draft.BpmDraftEx;
import com.quick.develop.flowable.domain.draft.BpmDraftPageReqVO;
import com.quick.develop.flowable.utils.mybatis.mapper.BaseMapperX;
import com.quick.develop.flowable.utils.mybatis.query.QueryWrapperX;
import com.quick.develop.framework.common.page.PageResult;

/**
 * @author junyuan.liu
 * @description:
 * @date 2022/6/16 10:34
 */
public interface BpmDraftMapper extends BaseMapperX<BpmDraftEx> {

    default PageResult<BpmDraftEx> selectPage(String userId, BpmDraftPageReqVO reqVO) {
        return selectPage(reqVO, new QueryWrapperX<BpmDraftEx>()
                .eq("CREATED_USER_CODE", userId)
                .likeIfPresent("PROCESS_NAME", reqVO.getProcessName())
                .betweenIfPresent("CREATED_DATE", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc("CREATED_DATE")
        );
    }

    default long getDraftCount(String userId) {
        return selectCount("CREATED_USER_CODE", userId);
    }

    /**
     * @param id ID
     * @return int
     * @description 物理删除草稿
     * @author junyuan.liu
     * @date 2022/6/16 11:15
     */
    int delDraftById(Long id);
}
